package com.leorui.schoollife.mapper

import com.leorui.schoollife.entity.SchoolEntity
import org.apache.ibatis.annotations.*

@Mapper
interface IDBSchool {
    @Insert("insert into user_school(school_name,school_web_url,parse_type) " +
            "value(#{schoolName},#{schoolUrl},#{parseType})")
    fun insertSchoolInfo(schoolName: String, schoolUrl: String, parseType: Int): Int?

    @Select("select school_id,school_name,school_web_url,parse_type from user_school where school_id = #{id}")
    @Results(value = [
        Result(id = true, column = "school_id", property = "schoolId"),
        Result(column = "school_name", property = "schoolName"),
        Result(column = "school_web_url", property = "schoolWebUrl"),
        Result(column = "parse_type", property = "parseType"),
    ])
    fun selectSchoolInfoById(id: Int): SchoolEntity?

    @Select("select school_id,school_name,school_web_url,parse_type from user_school")
    @Results(value = [
        Result(id = true, column = "school_id", property = "schoolId"),
        Result(column = "school_name", property = "schoolName"),
        Result(column = "school_web_url", property = "schoolWebUrl"),
        Result(column = "parse_type", property = "parseType"),
    ])
    fun selectAllSchoolInfo(): List<SchoolEntity?>?

    @Delete("delete from user_school where school_id = #{id}")
    fun deleteSchoolInfoById(id: Int): Int?
}